﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
namespace WPFExcelReport
{
    public partial class UIABE : ViewBase
    {
        #region ==VU1===========
        public static readonly DependencyProperty VU1Property = DependencyProperty.Register("VU1",
            typeof(string), typeof(UIABE),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVU1Changed));
        public string VU1
        {
            get
            {
                return (string)GetValue(VU1Property);
            }
            set
            {
                SetValue(VU1Property, value);
                OnVU1Chg(value);
            }
        }
        private static void OnVU1Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABE;
            if (src != null)
            {
                src.VU1 = (string)e.NewValue;
            }
        }
        public virtual void OnVU1Chg(string value)
        { }
        #endregion
        public VABARTE TMV
        {
            get
            {
                return (VABARTE)MV;
            }
        }
        public UIABE()
        { }

        public virtual void WERTN_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        { 
            if (e.Key != System.Windows.Input.Key.Enter)
                return;
            if (e.Key != System.Windows.Input.Key.Return)
                return;
            if (dwMaster == null)
                return;
            this.Focus();
            TMV.ABEWERTN = Helpers.Helper.Right("0000000000000000" + TMV.ABEWERTN, 16); 
            TMV.ABEWERTX = (double.Parse(TMV.ABEWERTN) * 0.000001).ToString().PadRight(16);
            TMV.UABE03(dwMaster );
            switch (dwMaster["ABEMESCHL"].ToString().Trim())
            {
                case "1":
                    VU1 = (1000 * decimal.Parse(TMV.ABEWERTN) / 1000 / 1000).ToString();
                    break;
            }
            TextBox t = sender as TextBox;
            vwMaster.View.MoveCurrentToNext();
            t.Focus(); 
        }
    }
}
